package com.wnhz.work.yz.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.utils.MyUtils;

/**
 * ----实名认证
 */
public class IdConfirmActivity extends BaseActivity implements View.OnClickListener {

    private EditText et_confirm_name;
    private EditText et_confirm_IdCard;

    private String inputName, inputCardNum;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_id_confirm);

        initTitle();
        initView();
    }

    private TextView title;

    private void initTitle() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("实名认证");
        findViewById(R.id.btn_main_left).setOnClickListener(this);
        TextView tv_right = (TextView) findViewById(R.id.view_main_right_text);
        tv_right.setText("下一步");
        tv_right.setTextColor(Color.parseColor("#008c99"));
        tv_right.setVisibility(View.VISIBLE);
        findViewById(R.id.btn_main_right).setVisibility(View.VISIBLE);
        findViewById(R.id.btn_main_right).setOnClickListener(this);
    }

    private void initView() {
        et_confirm_name = (EditText) findViewById(R.id.et_confirm_name);
        et_confirm_IdCard = (EditText) findViewById(R.id.et_confirm_IdCard);

    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {

            case R.id.btn_main_left:
                finish();
                break;
            //下一步
            case R.id.btn_main_right:
                inputName = et_confirm_name.getText().toString().trim();
                inputCardNum = et_confirm_IdCard.getText().toString().trim();
                if (!"".equals(inputName) && !"".equals(inputCardNum)) {
                    if (MyUtils.isIDCard(inputCardNum)) {
                        intent = new Intent(IdConfirmActivity.this, UploadCardActivity.class);
                        intent.putExtra("realname", inputName);
                        intent.putExtra("card_id", inputCardNum);
                        startActivity(intent);
                    } else {
                        MyToast("请输入正确的身份证号码");
                    }
                } else if ("".equals(inputName)) {
                    MyToast("姓名不能为空");
                } else if ("".equals(inputCardNum)) {
                    MyToast("身份证号码不能为空");
                }
                break;

            default:
                break;
        }
    }

}
